package com.csun.cmny.provider.dao;

import com.csun.cmny.provider.model.domain.DmcDevice;
import com.csun.cmny.provider.model.dto.device.DevicePageQuery;
import com.csun.cmny.provider.model.dto.device.DeviceQueryDto;
import com.csun.cmny.provider.model.dto.device.DeviceReqDto;
import com.csun.cmny.provider.model.dto.propertyManagement.DeviceDeriveExcelDto;
import com.csun.cmny.provider.model.dto.propertyManagement.MerchantSaveDeviceDto;
import com.csun.cmny.provider.model.dto.version.DeviceUpdateDto;
import com.csun.cmny.provider.model.vo.DeviceCountVo;
import com.csun.cmny.provider.model.vo.DmcBedsideScreenVo;
import com.csun.cmny.provider.model.vo.DmcCMBedsideScreenVo;
import com.csun.cmny.provider.model.vo.device.DeviceTypeVo;
import com.csun.cmny.provider.model.vo.device.DmcDeviceVo;
import com.csun.cmny.provider.model.vo.life.DmcDeviceByRoom;
import com.csun.cmny.provider.model.vo.propertyManagement.PropertyManagementDeviceVo;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public interface DmcDeviceMapper extends Mapper<DmcDevice> {

    /**
     * 根据deviceId查询设备信息
     *
     * @param deviceId 设备Id
     *
     * @return DeviceReqDto 设备信息
     */
    DeviceReqDto getDeviceById(Long deviceId);

    /**
     * select by group id list
     *
     * @param devicePageQuery   the device page query
     *
     * @return  the list
     */
    List<DmcDeviceVo> queryDeviceListWithPage(DevicePageQuery devicePageQuery);
    /**
     * @description: TODO 根据机构ID查询所有设备的数量
     * @param: groupId 机构Id
     * @return: 设备总数
     * @throws 
     * @author huangxm
     * @date 2019/3/8 14:32 
     */
    Integer getDeviceSum(@Param(value = "groupId") Long groupId,@Param("deviceType")Integer deviceType);

    /**
     * @param: groupId 机构Id
     * @return: DeviceCountVo
     */
    List<DeviceCountVo> queryDeviceNumByGroupByDeviceType(@Param("groupId") Long groupId);

    /**
     * 通过设备编号查询设备详情
     * @param deviceNo
     * @return
     */
    DmcDevice queryDeviceByNumber(@Param("deviceNo") String deviceNo);

    /**
     * 根据设备类型查询绑定的设备
     * @param userId  用户ID
     * @param deviceType 设备类型
     * @return
     */
    List<DmcDevice> queryDeviceBindList(@Param("userId") Long userId,@Param("deviceType") Integer deviceType);

    /**
     * 根据设备id集合查询设备集合
     * @param: [deviceIdList]
     * @return: java.util.List<com.csun.cmny.provider.model.vo.DmcDeviceVo>
     */
    List<DmcDeviceVo> queryDeviceListByIdList(@Param("deviceIdList") List<Long> deviceIdList);

    /**
     * 根据设备编号查询设备信息
     *
     * @param deviceNoList the device no list
     *
     * @return the list.
     */
    List<DeviceTypeVo> queryDeviceByDeviceNoList(@Param("deviceNoList") List<String> deviceNoList);

    /**
     *
     * @param devicePageQuery
     * @return
     */
    List<DmcBedsideScreenVo> queryBedsideListWithPage(DevicePageQuery devicePageQuery);

    /**
     *
     * @param devicePageQuery
     * @return
     */
    List<DmcCMBedsideScreenVo> queryCMBedsideListWithPage(DevicePageQuery devicePageQuery);

    /**
     *
     * @param roomId
     * @param groupId
     * @return
     */
    List<DmcDeviceByRoom> selectDeviceByRoomId(@Param("roomId") Long roomId,@Param("groupId") Long groupId);


    /**
     * 根据设备id查询房间id
     * @param deviceIds
     * @return
     */
    List<DmcDeviceByRoom> selectRoomIdByDevice(@Param("deviceIds") List<Long> deviceIds);

    /**
     * 更新设备版本号
     *
     * @param deviceId      the device id
     * @param deviceVersion the device version
     *
     * @return the int
     */
    Integer updateDeviceVersion(@Param("deviceId") Long deviceId, @Param("deviceVersion") String deviceVersion);

    /**
     * query update device list
     *
     * @param deviceUpdateDto   the device update dto
     *
     * @return  the list.
     */
    List<DmcDevice> queryUpdateDeviceList(DeviceUpdateDto deviceUpdateDto);

    /**
     * 查询设备列表
     *
     * @param deviceQueryDto the device query dto
     *
     * @return the list
     */
    List<DmcDevice> queryDeviceList(DeviceQueryDto deviceQueryDto);

    /**
     * 更新设备版本号
     *
     * @param deviceNo  the device no
     * @param version   the version
     *
     * @return  the int.
     */
    Integer updateDeviceVersionByDeviceNo(@Param("deviceNo") String deviceNo, @Param("version") String version);

    List<PropertyManagementDeviceVo> selectDeviceByDeviceIds(DeviceDeriveExcelDto deriveExcelDto);

    int saves(@Param("devices") List<DmcDevice> devices);

    int deleteManagements(@Param("deviceIds") List<Long> deviceIds);

    /**
     * select device id list
     *
     * @param devicePageQuery
     *
     * @return
     */
    List<Long> selectDeviceIdList(DevicePageQuery devicePageQuery);

    int bindDeviceGroup(@Param("deviceNos") ArrayList<String> deviceNos,@Param("groupId") Long groupId);

    int bindOnedeviceGroup(@Param("merchantSaveDeviceDto") MerchantSaveDeviceDto merchantSaveDeviceDto, @Param("groupId") Long groupId);

    int deleteuntie(@Param("deviceIds") List<Long> deviceIds);
}